<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$user = Mage::getSingleton('admin/session')->getUser();
$link = Mage::getModel('backend/backend')->load($user->getUserId(), 'user_id');
$user2 = Mage::registry('backend_data');
$link2 = Mage::getModel('backend/backend')->load($user2->getUserId(), 'user_id');
$customer = Mage::getModel('customer/customer')->load($link2->getCustomerId());
$addresses = $customer->getAddresses();
//$address = $addresses[0];
?>
<div class="entry-edit">
    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('backend')->__('Account Information') ?></h4>
    </div>
    <fieldset id="name">
    <?php if($this->getProductId()): ?>
        <ul class="messages">
            <li class="notice-msg">
                <ul>
                    <li><?php// echo Mage::helper('backend')->__("Items that you don't want to show in the catalog or search results should have status 'Disabled' in the desired store.") ?></li>
                </ul>
            </li>
        </ul>
    <?php endif; ?>
        <h4><div><?php echo "Username:     "?><?php echo $user2->getUsername()?><br><input name="username1" type="text" id="unamei"  value="<?php echo $user2->getUsername()?>">
            </div></h4>

        <h4><div><?php echo "First Name:     "?><?php echo $user2->getFirstname()?> <br><input name="firstname" type="text" id="fnamei"  value="<?php echo $user2->getFirstname()?>">
            </div><a href="javascript:display('fnamei','fname')" id="fname">Edit</a></h4>

        <h4><div><?php echo "Last Name:     "?><?php echo $user2->getLastname()?> <br><input name="lastname" type="text" id="lnamei"  value="<?php echo $user2->getLastname()?>">
            </div><a href="javascript:display('lnamei','lname')" id="lname">Edit</a></h4>
        <?php if(Mage::getSingleton('admin/session')->getUser()->getRole()->getRoleName()=="Administrators"){?>
            <h4><div><?php echo "Store ID:     "?><?php echo $link2->getStoreId()?> <br>
                    <select id="idi" name="store_id">
            <?php
                $sites = Mage::getModel('core/website')->getCollection();
                foreach($sites as $site){
                    echo "<option label='{$site->getName()}' value='{$site->getId()}'>{$site->getId()}</option>";
                    $webvalues[]=array(
                        'value'=> $site->getId(),
                        'label'=> $site->getName(),
                    );
                }
            ?>
                    </select>
            <!--<input name="store_id" type="text" id="idi"  value="<?php echo $link2->getStoreId()?>">-->
            </div><a href="javascript:display('idi','id')" id="id">Edit</a></h4>
            
            <!--<button class="save" type="button" onclick="saveAndContinueEdit()"><span><?php echo $this->__('Save') ?></span></button>-->
            <?php }?>
            <h4><a href="#" onclick="saveAndContinueEdit()">Save</a></h4>
    </fieldset>
</div>
<div class="entry-edit">
    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('backend')->__('Email Address') ?></h4>
    </div>
    <fieldset id="email_field">
    <?php if($this->getProductId()): ?>
        <ul class="messages">
            <li class="notice-msg">
                <ul>
                    <li><?php// echo Mage::helper('backend')->__("Items that you don't want to show in the catalog or search results should have status 'Disabled' in the desired store.") ?></li>
                </ul>
            </li>
        </ul>
    <?php endif; ?>
        <h4><div><?php echo "Email Address:     "?><?php echo $user2->getEmail()?> <br>
                <div id="emaili">
                    New Email:<br><input name="email" type="text" value="<?php echo $user2->getEmail()?>"><br>
                    <!--Confirm New Email:<br><input name="confirme" type="text" value=""><br>-->
                </div>
            </div><a href="javascript:display('emaili','email')" id="email">Edit</a></h4>
        <h4><a href="#" onclick="saveAndContinueEdit()">Save</a></h4>
    </fieldset>
</div>
<div class="entry-edit">
    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('backend')->__('Password') ?></h4>
    </div>
    <fieldset id="pass_field">
    <?php if($this->getProductId()): ?>
        <ul class="messages">
            <li class="notice-msg">
                <ul>
                    <li><?php// echo Mage::helper('backend')->__("Items that you don't want to show in the catalog or search results should have status 'Disabled' in the desired store.") ?></li>
                </ul>
            </li>
        </ul>
    <?php endif; ?>
        <h4><div><?php echo "Password: (hidden)"?><br>
                <div id="passi">
                    <!--Old Password:<br><input name="oldpassword" type="password" value=""><br>-->
                    New Password:<br><input name="newpassword" type="password" class="input-text validate-admin-password"><br>
                    Confirm New Password:<br><input name="confirmp" type="password" class="input-text validate-cpassword"><br>
                </div>
            </div><a href="javascript:display('passi','pass')" id="pass">Edit</a></h4>
        <h4><a href="#" onclick="saveAndContinueEdit()">Save</a></h4>
    </fieldset>
</div>


<div class="entry-edit">
    <div class="entry-edit-head">
        <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('backend')->__('Address') ?></h4>
    </div>
    <fieldset id="addr_field">
    <?php if($this->getProductId()): ?>
        <ul class="messages">
            <li class="notice-msg">
                <ul>
                    <li><?php// echo Mage::helper('backend')->__("Items that you don't want to show in the catalog or search results should have status 'Disabled' in the desired store.") ?></li>
                </ul>
            </li>
        </ul>
    <?php endif; ?>
        <?php $i=0; foreach($addresses as $address){ ?>
        <h4><div><?php echo "Address #".($i+1).": "?><br>
                    <?php echo $address->getFirstname()." ".$address->getLastname();?><br>
                    <?php echo $address->getStreetFull();?><br>
                    <?php echo $address->getCity()." ".$address->getRegion()." ".$address->getPostcode(); ?><br>
                    <?php echo $address->getTelephone();?><br>
                    <?php echo $address->getFax();?>
                <div id="addri_<?=$i?>">
                    <ul>
                        <li>
                            <div style="float:left">
                                <label for="addr_fname_<?=$i?>">First Name:</label><br/>
                                <input id="addr_fname_<?=$i?>" name="addr_fname_<?=$i?>" type="text" value="<?=$address->getFirstname()?>">
                            </div>
                            <div style="float:left;padding-left:20px">
                                <label for="addr_lname_<?=$i?>">Last Name:</label><br/>
                                <input id="addr_lname_<?=$i?>" name="addr_lname_<?=$i?>" type="text" value="<?=$address->getLastname()?>">
                            </div>
                        </li>
                        <li>
                            <div style="float:left">
                                <label for="addr_street_<?=$i?>">Street:</label><br/>
                                <input style="width:200px" id="addr_street_<?=$i?>" name="addr_street_<?=$i?>" type="text" value="<?=$address->getStreetFull()?>">
                            </div>
                        </li>
                        <li>
                            <div style="float:left">
                                <label for="addr_city_<?=$i?>">City:</label><br/>
                                <input id="addr_city_<?=$i?>" name="addr_city_<?=$i?>" type="text" value="<?=$address->getCity()?>">
                            </div>
                            <div style="float:left;padding-left:20px">
                                <label for="addr_region_<?=$i?>">State:</label><br/>
                                <input style="width:30px" id="addr_region_<?=$i?>" name="addr_region_<?=$i?>" type="text" value="<?=$address->getRegion()?>">
                            </div>
                            <div style="float:left;padding-left:20px">
                                <label for="addr_postcode_<?=$i?>">ZIP:</label><br/>
                                <input style="width:50px" id="addr_postcode_<?=$i?>" name="addr_postcode_<?=$i?>" type="text" value="<?=$address->getPostcode()?>">
                            </div>
                        </li>
                        <li>
                            <div style="float:left">
                                <label for="addr_telephone_<?=$i?>">Telephone:</label><br/>
                                <input id="addr_telephone_<?=$i?>" name="addr_telephone_<?=$i?>" type="text" value="<?=$address->getTelephone()?>">
                            </div>
                            <div style="float:left;padding-left:20px">
                                <label for="addr_fax_<?=$i?>">Fax:</label><br/>
                                <input id="addr_fax_<?=$i?>" name="addr_fax_<?=$i?>" type="text" value="<?=$address->getFax()?>">
                            </div>
                        </li>
                        <li>
                            <input type="checkbox" name="delete_<?=$i?>" value="yes"> Delete Address?
                        </li>
                    </ul>
                </div>
                    <input type="hidden" name="entity_id_<?=$i?>" value="<?php echo $address->getData('entity_id')?>">
            </div><a href="javascript:display('addri_<?=$i?>','addr_<?=$i?>')" id="addr_<?=$i?>">Edit</a></h4>
            
        <?php $i++;} ?>
        <h4><div id="addri_<?=$i?>">
                New Address:
                    <ul>
                        <li>
                            <div style="float:left">
                                <label for="addr_fname_<?=$i?>">First Name:</label><br/>
                                <input id="addr_fname_<?=$i?>" name="addr_fname_<?=$i?>" type="text" value="">
                            </div>
                            <div style="float:left;padding-left:20px">
                                <label for="addr_lname_<?=$i?>">Last Name:</label><br/>
                                <input id="addr_lname_<?=$i?>" name="addr_lname_<?=$i?>" type="text" value="">
                            </div>
                        </li>
                        <li>
                            <div style="float:left">
                                <label for="addr_street_<?=$i?>">Street:</label><br/>
                                <input style="width:200px" id="addr_street_<?=$i?>" name="addr_street_<?=$i?>" type="text" value="">
                            </div>
                        </li>
                        <li>
                            <div style="float:left">
                                <label for="addr_city_<?=$i?>">City:</label><br/>
                                <input id="addr_city_<?=$i?>" name="addr_city_<?=$i?>" type="text" value="">
                            </div>
                            <div style="float:left;padding-left:20px">
                                <label for="addr_region_<?=$i?>">State:</label><br/>
                                <input style="width:30px" id="addr_region_<?=$i?>" name="addr_region_<?=$i?>" type="text" value="">
                            </div>
                            <div style="float:left;padding-left:20px">
                                <label for="addr_postcode_<?=$i?>">ZIP:</label><br/>
                                <input style="width:50px" id="addr_postcode_<?=$i?>" name="addr_postcode_<?=$i?>" type="text" value="">
                            </div>
                        </li>
                        <li>
                            <div style="float:left">
                                <label for="addr_telephone_<?=$i?>">Telephone:</label><br/>
                                <input id="addr_telephone_<?=$i?>" name="addr_telephone_<?=$i?>" type="text" value="">
                            </div>
                            <div style="float:left;padding-left:20px">
                                <label for="addr_fax_<?=$i?>">Fax:</label><br/>
                                <input id="addr_fax_<?=$i?>" name="addr_fax_<?=$i?>" type="text" value="">
                            </div>
                        </li>
                    </ul>
                </div>
        <a href="javascript:display('addri_<?=$i?>','addr_<?=$i?>')" id="addr_<?=$i?>">Add</a></h4>
        <h4><a href="#" onclick="saveAndContinueEdit()">Save</a></h4>
        <? $i++;?>
            <input type="hidden" name="addr_count" value="<?=$i?>">

            
    </fieldset>
</div>

<script type="text/javascript">
    document.getElementById('unamei').style.display = "none";
    document.getElementById('fnamei').style.display = "none";
    document.getElementById('lnamei').style.display = "none";
    document.getElementById('emaili').style.display = "none";
    document.getElementById('passi').style.display = "none";
    <?php if(Mage::getSingleton('admin/session')->getUser()->getRole()->getRoleName()=="Administrators"){?>
    document.getElementById('idi').style.display = "none";
    //document.getElementById('commi').style.display = "none";
    <? }?>
    document.getElementById('addri_0').style.display = "none";
    for (i=0;i<=<?=$i?>;i++){
        document.getElementById('addri_'+i).style.display = "none";
    }
    function display(id, id2)
    {
        Effect.Appear(id);

        //document.getElementById(id).style.display = "block";
        document.getElementById(id2).style.display = "none";
    }
</script>